package com.example.design.proxy.demo2;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 动态代理
 */
public class ProxyHandler implements InvocationHandler {

    private  Object object;
    public  ProxyHandler(Object object){
        this.object=object;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        /**
         * 增强部分
         */

        System.out.println("======log--before");
        Object result = method.invoke(object, args);
        System.out.println("============log--after");
        return result;
    }
}
